from typing import Union
from pydantic import BaseModel


class SchemaSchema(BaseModel):
    id: str
    name: Union[str]
    desc: Union[str, None]


class SchemaCreateSchema(BaseModel):
    schema_id: str
    name: str
    desc: Union[str, None]


class SchemaUpdateSchema(BaseModel):
    id: str
    name: Union[str, None]
    desc: Union[str, None]
    fields: Union[list, None]


class FieldCreateSchema(BaseModel):
    name: str
    meta: str
    desc: Union[str, None]


class FieldSchema(BaseModel):
    id: Union[int, None]
    name: Union[int, None]
    meta: Union[dict, None]
    desc: Union[str, None]
    deleted: Union[bool, None]
    schema_id: Union[int, None]


class EntitySchema(BaseModel):
    id: str
    key: Union[str]


class ValueSchema(BaseModel):
    id: str
    value: Union[str, None]


class ValueCreateSchema(BaseModel):
    schema_id: str
    data: dict


class ValueImportSchema(BaseModel):
    schema_id: int
    unique: str


class FieldUpdateSchema(BaseModel):
    id: int
    name: Union[str, None]
    label: Union[str, None]
    meta: Union[dict, None]
    desc: Union[list, None]


class instanceUpdateSchema(BaseModel):
    instance_id: str
    data: dict


class instanceImportSchema(BaseModel):
    schema_id: str
    unique: str
    data: Union[list, None]


class instanceQuerySchema(BaseModel):
    schema_id: str
    page: Union[int, None] = 0
    rows: Union[int, None] = 10
    query: Union[list, None] = []
